{include header}
<div class="wrapper">
    {include header_menu}

    {include left_menu}
    <div class="main-container">
        <div class="padding-md">
            <h2 class="header-text no-margin">
                用户 - 管理
            </h2>
            <div class="gallery-filter m-top-md m-bottom-md">
                <ul class="clearfix">
                    <li class="active"><a href="javascript:void(0)" data-toggle="modal" data-target="#normalModal"><i class="fa fa-plus"></i> 添加用户</a></li>

                    
                    
                </ul>
            </div>
            
            <style>

            .table-striped>tbody>tr{
                    cursor: pointer;
            }
            </style>
            <script>
            (function(){

            });
            function edit_forum(obj){
                var i=0,ii=0;
                $("#edit0").val('');
                $("#edit1").val('');
                $("#edit2").val('-1');
                $(obj).parent().parent().find('td').each(function(e){
                        if(ii++ == 0)
                            return;
                        
                        $("#edit"+(i++)).val($(this).attr("data"));
                    

                })
                $('#normalModal1').modal('show')
            }
            function deluser(id,obj){ //删除用户
                if(!confirm("确定删除?")){
                    return;
                }

                $(obj).attr("disabled",true);
                $.post(window.location.pathname,{id:id,gn:4},function(e){
                    $(obj).removeAttr("disabled");
                    if(e.error){
                        $(obj).parent().parent().remove();
                    }

                },'json');
            }
            </script>
            <div class="row" style="    margin-top: 10px;">
                <div class="col-md-3">
                    <div class="widget-stat clearfix">
                        <span class="stat-icon bg-info bounceIn animation-delay3"><i class="fa fa-users"></i></span>
                        <div class="stat-info">
                            <small class="text-muted text-upper">站点用户数量</small>
                            <span>{$user_count}</span>
                        </div>
                    </div>
                </div>
                <div class="col-md-3">
                    <div class="widget-stat clearfix">
                        <span class="stat-icon bg-success bounceIn animation-delay3"><i class="fa fa-user-plus"></i></span>
                        <div class="stat-info">
                            <small class="text-muted text-upper">今日注册</small>
                            <span>{$day_count}</span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row" style="    margin-top: 10px;">
            <form method="get">
                <input type="hidden" name="gn" value="1" />
                <div class="col-md-4 col-xs-12">
                    <div class="form-group">
                        <label>搜索用户 (或邮箱)</label>
                        <input name="user"  type="text" class="form-control" value="{if isset($skey)}{$skey}{/if}" placeholder="关键字 - 不搜索请留空">
                    </div>
                </div>
                <div class="col-md-4 col-xs-12">
                    <div class="form-group">
                        <label>筛选用户组</label>
                        <select class="form-control" name="usergroup">
                            <option value="0">选择用户组</option>
                            {foreach $usergroup as $v}
                            <option value="{$v.id}" {if isset($sgroup)}{if $sgroup == $v['id']}selected = "selected" {/if}{/if}>{$v.name}</option>
                            {/foreach}
                        </select>
                        
                    </div>
                </div>
                <div class="col-md-4 col-xs-12">
                <label>&nbsp;</label>
                    <div class="form-group">
                        <button type="submit" class="btn btn-success btn-sm">筛选</button>
                    </div>
                </div>
            </form>
            </div>
            <form action="" method="post">
            <input type="hidden" name="gn" value="del_more">
            <div class="table-responsive">
                <table class="table table-striped table-bordered m-top-md" id="dataTable">
    				<thead>
    					<tr class="bg-dark-blue">
                            <th>
                                <div class="custom-checkbox">
                                  <input type="checkbox" id="chkx" onclick="if($(this).is(':checked'))$('.checkboxx').prop('checked','checked'); else $('.checkboxx').attr('checked',false);">
                                  <label for="chkx"></label>
                                </div>
                            </th>
    						<th>用户ID</th>
    						<th>用户名称</th>
                            <th>用户组 ID</th>
    						<th>Email</th>
                            <th>文章数量</th>
                            <th>评论数量</th>
                            <th>注册时间</th>
                            <th>金币</th>
                            <th>积分</th>
                            <th>粉丝</th>
                            <th>关注</th>
                            <th>已用文件空间(kb)</th>
                            <th>已用聊天空间(b)</th>
                            <th>操作</th>
    					</tr>
    				</thead>
    				<tbody>
                        {foreach $data as $v}
                        <tr>
                            <td>
                                <div class="custom-checkbox">
                                  <input name="id[]" value="{$v.id}" class="checkboxx" type="checkbox" id="chk{$v.id}">
                                  <label for="chk{$v.id}"></label>
                                </div>
                              </td>
                            <td data="{$v.id}">{$v.id}</td>
                            <td data="{$v.user}">{$v.user}</td>
                            <td data="{$v.group}">{$v.group},{$usergroup[$v['group']]['name']}</td>
                            <td data="{$v.email}">{$v.email}</td>
                            <td>{$v.threads}</td>
                            <td>{$v.posts}</td>
                            
                            <td><?php echo empty($v['atime'])?'史前生物':date("Y-m-d H:i:s",$v['atime']) ?></td>
                            <td data="{$v.gold}">{$v.gold}</td>
                            <td data="{$v.credits}">{$v.credits}</td>
                            <td data="{$v.follow}">{$v.follow}</td>
                            <td data="{$v.fans}">{$v.fans}</td>
                            <td data="{$v.file_size}">{$v.file_size}</td>
                            <td data="{$v.file_size}">{$v.chat_size}</td>
                            <td>
                                <button type="button" onclick="edit_forum(this)" class="btn btn-success btn-xs">编辑</button>
                                {if C('ADMIN_GROUP') != $v['group']}
                                <button type="button" onclick="deluser({$v.id},this)" class="btn btn-danger btn-xs">删除</button>
                                {/if}
                            </td>
                        </tr>
                        {/foreach}


    				</tbody>
    			</table>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="checkbox inline-block">
                        <div class="custom-checkbox">
                            <input type="checkbox" name="del_post" id="inlineCheckbox1" class="checkbox-red" >
                            <label for="inlineCheckbox1"></label>
                        </div>
                        <div class="inline-block vertical-top">
                            勾选此项确认删除
                        </div>
                    </div>
                    
                </div>
                <div class="col-md-12">
                    <button class="btn btn-danger">删除勾选用户 (不可恢复)</button>
                </div>
            </div>
            </form>
            <div class="smart-widget-body">


				<a href="{if $pageid==1}javascript:void(0);{else}?pageid={$pageid-1}{$fj}{/if}" class="btn btn-success marginTB-xs" {if $pageid==1}disabled{/if}><i class="fa fa-angle-double-left m-left-xs"></i> 上一页</a>

				<a href="{if $pageid==$page_count}javascript:void(0);{else}?pageid={$pageid+1}{$fj}{/if}" style="float:right" class="btn btn-success marginTB-xs" {if $pageid==$page_count}disabled{/if}>下一页<i class="fa fa-angle-double-right m-left-xs"></i></a>


			</div>
            <div class="alert alert-danger alert-custom alert-dismissible" role="alert">
		    	
		     	<i class="fa fa-times-circle m-right-xs"></i> <strong>警告!</strong> 删除用户特殊警告： 当你删除用户后，他的所有文章，评论，附件，文件，图片，聊天记录，好友粉丝等。管他的一切都会被删除。而且无法恢复他的数据！
		    </div>
            
        </div><!-- ENd box  -->

    </div>
</div>

<!-- Modal -->
    <form method="post">
    <div class="modal fade" id="normalModal">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">添加用户</h4>
                </div>
                <div class="modal-body">
                    <input type="hidden" name="gn" value="2">
                    <div class="form-group">
                        <label for="">用户名</label>
                        <input type="text" name="user" class="form-control" >
                    </div>
                    <div class="form-group">
                        <label for="">用户组</label>
                        
                        <select class="form-control" name="group">
                            {foreach $usergroup as $v}
                            <option value="{$v.id}" {if $v['id']==2} selected="selected" {/if}>{$v.name}</option>
                            {/foreach}
                        </select>

                    </div>
                    <div class="form-group">
                        <label for="">邮箱</label>
                        <input type="email" name="email" class="form-control" >
                    </div>
                    <div class="form-group">
                        <label for="">密码</label>
                        <input type="text" name="pass" class="form-control" >
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </div>
        </div>
    </div>
    </form>

    <form method="post">
    <div class="modal fade" id="normalModal1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">修改用户</h4>
                </div>
                <div class="modal-body">
                    <input type="hidden" name="gn" value="3">
                    <input type="hidden" name="id" id="edit0">

                    <div class="form-group">
                        <label for="">用户名</label>
                        <input name="user" id="edit1" type="text" class="form-control" >
                    </div>
                    <div class="form-group">
                        <label for="">用户组</label>
                        
                        <select class="form-control" id="edit2" name="group">
                            {foreach $usergroup as $v}
                            <option value="{$v.id}">{$v.name}</option>
                            {/foreach}
                        </select>

                    </div>
                    <div class="form-group">
                        <label for="">邮箱</label>
                        <input name="email" id="edit3" type="email" class="form-control" >
                    </div>
                    <div class="form-group">
                        <label for="">密码 (留空则不修改)</label>
                        <input name="pass" id="" type="text" class="form-control">
                    </div>
                    <div class="form-group">
                        <label for="">金币</label>
                        <input name="gold" id="edit7" type="text" class="form-control">
                    </div>
                    <div class="form-group">
                        <label for="">积分</label>
                        <input name="credits" id="edit8" type="text" class="form-control">
                    </div>
                    
                
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </div>
        </div>
    </div>
    </form>
    <!-- !Modal -->


{include footer}
